home *** CD-ROM | disk | FTP | other *** search
/ Visual Cafe 3 / Visual Cafe 3.ISO / Vcafe / Source.bin / LabelButton.java < prev    next >
Text File  |  1998-08-21  |  23KB  |  692 lines

  1. package symantec.itools.awt;
  2.  
  3. import java.awt.Color;
  4. import java.awt.Dimension;
  5. import java.awt.FontMetrics;
  6. import java.awt.Font;
  7. import java.awt.Graphics;
  8. import java.beans.PropertyVetoException;
  9. import java.beans.PropertyChangeListener;
  10. import java.beans.VetoableChangeListener;
  11. import java.beans.PropertyChangeEvent;
  12. import java.lang.IllegalArgumentException;
  13. import symantec.itools.awt.util.ColorUtils;
  14. import java.util.ResourceBundle;
  15.  
  16. //     01/29/97    TWB    Integrated changes from Macintosh
  17. //     02/27/97    RKM    Merged in Scott's changes
  18. //     05/31/97    LAB Updated to Java 1.1
  19. //     07/09/97    LAB Changed the way the button is drawn.  Now it uses the offscreen
  20. //                    Image.  Cleaned up the drawing code to be more universal.
  21. //                    Added pressed and disabled colors for the text durring those states.
  22. //                    Added a VerticalAlignStyle property to align the text vertically.
  23. //                    Added a preferedSize() method that works.
  24. //                    Removed BevelStyle, Show/HideLabel, and BorderIndent.
  25. //                    No longer overrides setFont(), minimumSize(), or paint().
  26. //    07/13/97    RKM    Fixed misspelling of prefered
  27. //     07/20/97    LAB    Fixed a logic problem when testing for null strings.
  28. //  07/23/97    CAR changed getPreferredSize
  29. //  07/23/97    CAR marked field transient as needed, inner classes implement java.io.Serializable
  30. //     08/05/97    LAB    Added a call to clipRect in the updateButtonImage method to clip subsequent
  31. //                    drawings to the internal button area (sans border and bevel). This should be
  32. //                    removed when the VM interprets the base class' call to clipRect correctly.
  33. //     08/06/97    LAB    Removed the call to clipRect; now uses the base classes buttonImageGraphics
  34. //                    Graphics to draw with, which inherits the clipping.
  35. //  08/19/97    CAR commented out duplicate call to setVerticalAlignStyle in constructor
  36.  
  37. /**
  38.  * LabelButton is a 3D looking button that displays a string on it's face.
  39.  * Use an LabelButton to:
  40.  * <UL>
  41.  * <DT>╖ Display text in a 3D looking button.</DT>
  42.  * <DT>╖ Generate a train of action events while the user presses the button.</DT>
  43.  * </UL>
  44.  * <p>
  45.  * @version 1.1, July 8, 1997
  46.  * @author  Symantec
  47.  */
  48. public class LabelButton extends ButtonBase implements AlignStyle
  49. {
  50.     /**
  51.      * Defines the "top" label text alignment style.
  52.      */
  53.     public static final int ALIGN_TOP = 0;
  54.  
  55.     /**
  56.      * Defines the "bottom" label text alignment style.
  57.      */
  58.     public static final int ALIGN_BOTTOM = 2;
  59.  
  60.     /**
  61.      * Constructs an empty LabelButton with center aligned black text.
  62.      */
  63.     public LabelButton()
  64.     {
  65.         this("", ALIGN_CENTERED, ALIGN_CENTERED, Color.black);
  66.     }
  67.  
  68.     /**
  69.      * Constructs a LabelButton with the specified centered, black text.
  70.      * @param sText the label text
  71.      */
  72.     public LabelButton(String sText)
  73.     {
  74.         this(sText, ALIGN_CENTERED, ALIGN_CENTERED, Color.black);
  75.     }
  76.  
  77.     /**
  78.      * Constructs a LabelButton with the specified centered text,
  79.      * with the specified color.
  80.      * @param sText the label text
  81.      */
  82.     public LabelButton(String sText, Color color)
  83.     {
  84.         this(sText, ALIGN_CENTERED, ALIGN_CENTERED, color);
  85.     }
  86.  
  87.     /**
  88.      * Constructs a LabelButton with the specified vertically centered black text, and the
  89.      * specified horizontal text alignment style.
  90.      * @param sText the label text
  91.      * @param alignStyle the text alignment style: ALIGN_LEFT, ALIGN_CENTERED, or ALIGN_RIGHT
  92.      * @see AlignStyle#ALIGN_LEFT
  93.      * @see AlignStyle#ALIGN_CENTERED
  94.      * @see AlignStyle#ALIGN_RIGHT
  95.      */
  96.     public LabelButton(String sText, int alignStyle)
  97.     {
  98.         this(sText, alignStyle, ALIGN_CENTERED, Color.black);
  99.     }
  100.  
  101.     /**
  102.      * Constructs a LabelButton with the specified attributes.
  103.      * @param sText the label text
  104.      * @param hAlignStyle the text horizontal alignment style: ALIGN_LEFT, ALIGN_CENTERED, or ALIGN_RIGHT
  105.      * @param vAlignStyle the text vertical alignment style: ALIGN_TOP, ALIGN_CENTERED, or ALIGN_BOTTOM
  106.      * @param color the label text color
  107.      * @see AlignStyle#ALIGN_LEFT
  108.      * @see AlignStyle#ALIGN_CENTERED
  109.      * @see AlignStyle#ALIGN_RIGHT
  110.      * @see #ALIGN_TOP
  111.      * @see #ALIGN_BOTTOM
  112.      */
  113.     public LabelButton(String sText, int hAlignStyle, int vAlignStyle, Color color)
  114.     {
  115.         try
  116.         {
  117.             setText(sText);
  118.             setTextColor(color);
  119.             setAlignStyle(hAlignStyle);
  120.             setVerticalAlignStyle(vAlignStyle);
  121.             //setVerticalAlignStyle(ALIGN_CENTERED);
  122.         }
  123.         catch(PropertyVetoException e){}
  124.     }
  125.  
  126.     /**
  127.      * Sets the text horizontal alignment style.
  128.      * Causes the component to redraw.
  129.      * @param style the text alignment style: ALIGN_LEFT, ALIGN_CENTERED, or ALIGN_RIGHT
  130.      * @see #getAlignStyle
  131.      * @see AlignStyle#ALIGN_LEFT
  132.      * @see AlignStyle#ALIGN_CENTERED
  133.      * @see AlignStyle#ALIGN_RIGHT
  134.      * @exception PropertyVetoException
  135.      * if the specified property value is unacceptable
  136.      */
  137.     public void setAlignStyle(int style) throws PropertyVetoException
  138.     {
  139.         if(hAlignStyle != style)
  140.         {
  141.             Integer oldValue = new Integer(hAlignStyle);
  142.             Integer newValue = new Integer(style);
  143.  
  144.             vetos.fireVetoableChange("AlignStyle", oldValue, newValue);
  145.  
  146.             hAlignStyle = style;
  147.             repaint();
  148.  
  149.             changes.firePropertyChange("AlignStyle", oldValue, newValue);
  150.         }
  151.     }
  152.  
  153.     /**
  154.      * Gets the current text alignment style.
  155.      * @return the text alignment style: ALIGN_LEFT, ALIGN_CENTERED, or ALIGN_RIGHT
  156.      * @see #setAlignStyle
  157.      * @see AlignStyle#ALIGN_LEFT
  158.      * @see AlignStyle#ALIGN_CENTERED
  159.      * @see AlignStyle#ALIGN_RIGHT
  160.      */
  161.     public int getAlignStyle()
  162.     {
  163.         return hAlignStyle;
  164.     }
  165.  
  166.     /**
  167.      * Sets the text vertical alignment style.
  168.      * Causes the component to redraw.
  169.      * @param style the text alignment style: ALIGN_TOP, ALIGN_CENTERED, or ALIGN_BOTTOM
  170.      * @see #getVerticalAlignStyle
  171.      * @see #ALIGN_TOP
  172.      * @see AlignStyle#ALIGN_CENTERED
  173.      * @see #ALIGN_BOTTOM
  174.      * @exception PropertyVetoException
  175.      * if the specified property value is unacceptable
  176.      */
  177.     public void setVerticalAlignStyle(int style) throws PropertyVetoException
  178.     {
  179.         if(vAlignStyle != style)
  180.         {
  181.             Integer oldValue = new Integer(vAlignStyle);
  182.             Integer newValue = new Integer(style);
  183.  
  184.             vetos.fireVetoableChange("VerticalAlignStyle", oldValue, newValue);
  185.  
  186.             vAlignStyle = style;
  187.             repaint();
  188.  
  189.             changes.firePropertyChange("VerticalAlignStyle", oldValue, newValue);
  190.         }
  191.     }
  192.  
  193.     /**
  194.      * Gets the current text alignment style.
  195.      * @return the text alignment style: ALIGN_TOP, ALIGN_CENTERED, or ALIGN_BOTTOM
  196.      * @see #setVerticalAlignStyle
  197.      * @see #ALIGN_TOP
  198.      * @see AlignStyle#ALIGN_CENTERED
  199.      * @see #ALIGN_BOTTOM
  200.      */
  201.     public int getVerticalAlignStyle()
  202.     {
  203.         return vAlignStyle;
  204.     }
  205.  
  206.     /**
  207.      * Sets the label text.
  208.      * Causes the component to redraw.
  209.      * @param sText the new label text
  210.      * @see #getText
  211.      * @exception PropertyVetoException
  212.      * if the specified property value is unacceptable
  213.      */
  214.     public void setText(String sText) throws PropertyVetoException
  215.     {
  216.         if(sLabelButton == null || !sLabelButton.equals(sText))
  217.         {
  218.             String oldValue = sLabelButton == null ? null : new String(sLabelButton);
  219.  
  220.             vetos.fireVetoableChange("Text", oldValue, sText);
  221.  
  222.             sLabelButton = sText;
  223.             repaint();
  224.  
  225.             changes.firePropertyChange("Text", oldValue, sText);
  226.         }
  227.     }
  228.  
  229.     /**
  230.      * Gets the current label text.
  231.      * @return the current label text
  232.      * @see #setText
  233.      */
  234.     public String getText()
  235.     {
  236.         return sLabelButton;
  237.     }
  238.  
  239.     /**
  240.      * Sets the label text color.
  241.      * Causes the component to redraw.
  242.      * @param color the new color for the label text
  243.      * @see #getTextColor
  244.      * @exception PropertyVetoException
  245.      * if the specified property value is unacceptable
  246.      */
  247.     public void setTextColor(Color color) throws PropertyVetoException
  248.     {
  249.         if(! symantec.itools.util.GeneralUtils.objectsEqual(textColor, color))
  250.         {
  251.             Color oldValue = textColor;
  252.  
  253.             vetos.fireVetoableChange("TextColor", oldValue, color);
  254.  
  255.             textColor = color;
  256.             try
  257.             {
  258.                 disabledTextColor    = ColorUtils.lighten(textColor,    0.333);
  259.                 pressedTextColor    = ColorUtils.darken(textColor,    0.250);
  260.             }
  261.             catch (IllegalArgumentException exc) {}
  262.             repaint();
  263.  
  264.             changes.firePropertyChange("TextColor", oldValue, color);
  265.         }
  266.     }
  267.  
  268.     /**
  269.      * Gets the current label text color.
  270.      * @return the current color of the label text
  271.      * @see #setTextColor
  272.      */
  273.     public Color getTextColor()
  274.     {
  275.         return textColor;
  276.     }
  277.  
  278.     /**
  279.      * Returns the recommended dimensions to properly display this component.
  280.      * This is a standard Java AWT method which gets called to determine
  281.      * the recommended size of this component.
  282.      *
  283.      * The Dimension returned is large enough for the label and a one pixel
  284.      * space between the label and the button's bevel.
  285.      */
  286.     public Dimension getPreferredSize()
  287.     {
  288.         if(isAdded)
  289.         {
  290.             Dimension s        = size();
  291.             Graphics g        = getGraphics();
  292.             FontMetrics fm    = g.getFontMetrics();
  293.             int labelWidth    = 0;
  294.  
  295.             //Make sure we don't cause a NullPointerException when accessing the string width.
  296.             if(!(sLabelButton == null || sLabelButton.equals("")))
  297.                 labelWidth = fm.stringWidth(sLabelButton);
  298.  
  299.             if (g != null)
  300.                 g.dispose();
  301.  
  302.             return new Dimension(labelWidth + bevel + bevel + 4, fm.getAscent() + fm.getDescent() + bevel + bevel + 4);
  303.         }
  304.         return super.getPreferredSize();
  305.     }
  306.  
  307.     /**
  308.      * Tells this component that it has been added to a container.
  309.      * This is a standard Java AWT method which gets called by the AWT when
  310.      * this component is added to a container. Typically, it is used to
  311.      * create this component's peer.
  312.      *
  313.      * It has been overridden here to hook-up event listeners.
  314.      *
  315.      * @see #removeNotify
  316.      */
  317.     public synchronized void addNotify()
  318.     {
  319.         super.addNotify();
  320.         errors = ResourceBundle.getBundle("symantec.itools.resources.ErrorsBundle");
  321.  
  322.         //Hook up listeners
  323.         if (horizontalVeto == null)
  324.         {
  325.             horizontalVeto = new HAVeto();
  326.             addAlignStyleListener(horizontalVeto);
  327.         }
  328.         if (verticalVeto == null)
  329.         {
  330.             verticalVeto = new VAVeto();
  331.             addVerticalAlignStyleListener(verticalVeto);
  332.         }
  333.     }
  334.  
  335.     /**
  336.      * Tells this component that it is being removed from a container.
  337.      * This is a standard Java AWT method which gets called by the AWT when
  338.      * this component is removed from a container. Typically, it is used to
  339.      * destroy the peers of this component and all its subcomponents.
  340.      *
  341.      * It has been overridden here to unhook event listeners.
  342.      *
  343.      * @see #addNotify
  344.      */
  345.     public synchronized void removeNotify()
  346.     {
  347.         //Unhook listeners
  348.         if (horizontalVeto != null)
  349.         {
  350.             removeAlignStyleListener(horizontalVeto);
  351.             horizontalVeto = null;
  352.         }
  353.         if (verticalVeto != null)
  354.         {
  355.             removeVerticalAlignStyleListener(verticalVeto);
  356.             verticalVeto = null;
  357.         }
  358.  
  359.         super.removeNotify();
  360.     }
  361.  
  362.     /**
  363.      * Adds a listener for all event changes.
  364.      * @param listener the listener to add.
  365.      * @see #removePropertyChangeListener
  366.      */
  367.     public synchronized void addPropertyChangeListener(PropertyChangeListener listener)
  368.     {
  369.         super.addPropertyChangeListener(listener);
  370.         changes.addPropertyChangeListener(listener);
  371.     }
  372.  
  373.     /**
  374.      * Removes a listener for all event changes.
  375.      * @param listener the listener to remove.
  376.      * @see #addPropertyChangeListener
  377.      */
  378.     public synchronized void removePropertyChangeListener(PropertyChangeListener listener)
  379.     {
  380.         super.removePropertyChangeListener(listener);
  381.         changes.removePropertyChangeListener(listener);
  382.     }
  383.  
  384.     /**
  385.      * Adds a vetoable listener for all event changes.
  386.      * @param listener the listener to add.
  387.      * @see #removeVetoableChangeListener(java.beans.VetoableChangeListener)
  388.      */
  389.     public synchronized void addVetoableChangeListener(VetoableChangeListener listener)
  390.     {
  391.         super.addVetoableChangeListener(listener);
  392.         vetos.addVetoableChangeListener(listener);
  393.     }
  394.  
  395.     /**
  396.      * Removes a vetoable listener for all event changes.
  397.      * @param listener the listener to remove.
  398.      * @see #addVetoableChangeListener(java.beans.VetoableChangeListener)
  399.      */
  400.     public synchronized void removeVetoableChangeListener(VetoableChangeListener listener)
  401.     {
  402.         super.removeVetoableChangeListener(listener);
  403.         vetos.removeVetoableChangeListener(listener);
  404.     }
  405.  
  406.     /**
  407.      * Adds a listener for the AlignStyle property changes.
  408.      * @param listener the listener to add.
  409.      * @see #removeAlignStyleListener(java.beans.PropertyChangeListener)
  410.      */
  411.     public synchronized void addAlignStyleListener(PropertyChangeListener listener)
  412.     {
  413.         changes.addPropertyChangeListener("AlignStyle", listener);
  414.     }
  415.  
  416.     /**
  417.      * Removes a listener for the AlignStyle property changes.
  418.      * @param listener the listener to remove.
  419.      * @see #addAlignStyleListener(java.beans.PropertyChangeListener)
  420.      */
  421.     public synchronized void removeAlignStyleListener(PropertyChangeListener listener)
  422.     {
  423.         changes.removePropertyChangeListener("AlignStyle", listener);
  424.     }
  425.  
  426.     /**
  427.      * Adds a vetoable listener for the AlignStyle property changes.
  428.      * @param listener the listener to add.
  429.      * @see #removeAlignStyleListener(java.beans.VetoableChangeListener)
  430.      */
  431.     public synchronized void addAlignStyleListener(VetoableChangeListener listener)
  432.     {
  433.         vetos.addVetoableChangeListener("AlignStyle", listener);
  434.     }
  435.  
  436.     /**
  437.      * Removes a vetoable listener for the AlignStyle property changes.
  438.      * @param listener the listener to remove.
  439.      * @see #addAlignStyleListener(java.beans.VetoableChangeListener)
  440.      */
  441.     public synchronized void removeAlignStyleListener(VetoableChangeListener listener)
  442.     {
  443.         vetos.removeVetoableChangeListener("AlignStyle", listener);
  444.     }
  445.  
  446.     /**
  447.      * Adds a listener for the VerticalAlignStyle property changes.
  448.      * @param listener the listener to add.
  449.      * @see #removeVerticalAlignStyleListener(java.beans.PropertyChangeListener)
  450.      */
  451.     public synchronized void addVerticalAlignStyleListener(PropertyChangeListener listener)
  452.     {
  453.         changes.addPropertyChangeListener("VerticalAlignStyle", listener);
  454.     }
  455.  
  456.     /**
  457.      * Removes a listener for the VerticalAlignStyle property changes.
  458.      * @param listener the listener to remove.
  459.      * @see #addVerticalAlignStyleListener(java.beans.PropertyChangeListener)
  460.      */
  461.     public synchronized void removeVerticalAlignStyleListener(PropertyChangeListener listener)
  462.     {
  463.         changes.removePropertyChangeListener("VerticalAlignStyle", listener);
  464.     }
  465.  
  466.     /**
  467.      * Adds a vetoable listener for the VerticalAlignStyle property changes.
  468.      * @param listener the listener to add.
  469.      * @see #removeVerticalAlignStyleListener(java.beans.VetoableChangeListener)
  470.      */
  471.     public synchronized void addVerticalAlignStyleListener(VetoableChangeListener listener)
  472.     {
  473.         vetos.addVetoableChangeListener("VerticalAlignStyle", listener);
  474.     }
  475.  
  476.     /**
  477.      * Removes a vetoable listener for the VerticalAlignStyle property changes.
  478.      * @param listener the listener to remove.
  479.      * @see #addVerticalAlignStyleListener(java.beans.VetoableChangeListener)
  480.      */
  481.     public synchronized void removeVerticalAlignStyleListener(VetoableChangeListener listener)
  482.     {
  483.         vetos.removeVetoableChangeListener("VerticalAlignStyle", listener);
  484.     }
  485.  
  486.     /**
  487.      * This is the PropertyChangeEvent handling inner class for the constrained AlignStyle property.
  488.      * Handles vetoing AlignStyles that are not valid.
  489.      */
  490.     class HAVeto implements java.beans.VetoableChangeListener, java.io.Serializable
  491.     {
  492.         /**
  493.          * This method gets called when an attempt to change the constrained AlignStyle property is made.
  494.          * Ensures the given AlignStyle is valid.
  495.          *
  496.          * @param     e a <code>PropertyChangeEvent</code> object describing the
  497.          *             event source and the property that has changed.
  498.          * @exception PropertyVetoException if the recipient wishes the property
  499.          *              change to be rolled back.
  500.          */
  501.         public void vetoableChange(PropertyChangeEvent e) throws PropertyVetoException
  502.         {
  503.             int i = ((Integer)e.getNewValue()).intValue();
  504.             if (!isValidHorizontalAlignStyle(i))
  505.             {
  506.                 throw new PropertyVetoException(errors.getString("InvalidAlignStyle") + i, e);
  507.             }
  508.         }
  509.     }
  510.  
  511.     /**
  512.      * This is the PropertyChangeEvent handling inner class for the constrained VerticalAlignStyle property.
  513.      * Handles vetoing VerticalAlignStyles that are not valid.
  514.      */
  515.     class VAVeto implements java.beans.VetoableChangeListener, java.io.Serializable
  516.     {
  517.         /**
  518.          * This method gets called when an attempt to change the constrained VerticalAlignStyle property is made.
  519.          * Ensures the given AlignStyle is valid.
  520.          *
  521.          * @param     e a <code>PropertyChangeEvent</code> object describing the
  522.          *             event source and the property that has changed.
  523.          * @exception PropertyVetoException if the recipient wishes the property
  524.          *              change to be rolled back.
  525.          */
  526.         public void vetoableChange(PropertyChangeEvent e) throws PropertyVetoException
  527.         {
  528.             int i = ((Integer)e.getNewValue()).intValue();
  529.             if (!isValidVerticalAlignStyle(i))
  530.             {
  531.                 throw new PropertyVetoException(errors.getString("InvalidVerticalAlignStyle") + i, e);
  532.             }
  533.         }
  534.     }
  535.  
  536.     /**
  537.      * Is the given Horizontal AlignStyle valid for this button.
  538.      * @param i the given Horizontal AlignStyle
  539.      * @return true if the given Horizontal AlignStyle is acceptable, false if not.
  540.      */
  541.     protected boolean isValidHorizontalAlignStyle(int i)
  542.     {
  543.         switch(i)
  544.         {
  545.             case ALIGN_LEFT:
  546.             case ALIGN_CENTERED:
  547.             case ALIGN_RIGHT:
  548.                 return true;
  549.             default:
  550.                 return false;
  551.         }
  552.     }
  553.  
  554.     /**
  555.      * Is the given Vertical AlignStyle valid for this button.
  556.      * @param i the given Vertical AlignStyle
  557.      * @return true if the given Vertical AlignStyle is acceptable, false if not.
  558.      */
  559.     protected boolean isValidVerticalAlignStyle(int i)
  560.     {
  561.         switch(i)
  562.         {
  563.             case ALIGN_TOP:
  564.             case ALIGN_CENTERED:
  565.             case ALIGN_BOTTOM:
  566.                 return true;
  567.             default:
  568.                 return false;
  569.         }
  570.     }
  571.  
  572.     /**
  573.      * Draws the button in the buttonImage offscreen image.
  574.      * This should only be called after the component is added to a container,
  575.      * to avoid a NullPointerException when accessing FontMetrics.
  576.      * @see symantec.itools.awt.ButtonBase#updateButtonImage
  577.      */
  578.     protected void updateButtonImage()
  579.     {
  580.         super.updateButtonImage();
  581.  
  582.         FontMetrics fm = buttonImageGraphics.getFontMetrics();
  583.         Color tempColor;
  584.         int xPos = 0;
  585.         int yPos = 0;
  586.         int labelWidth = 0;
  587.         Dimension s = size();
  588.  
  589.         //Make sure we don't cause a NullPointerException when accessing the string width.
  590.         if(!(sLabelButton == null || sLabelButton.equals("")))
  591.             labelWidth = fm.stringWidth(sLabelButton);
  592.  
  593.         if(isEnabled())
  594.         {
  595.             if(pressed)
  596.                 tempColor = pressedTextColor;
  597.             else
  598.                 tempColor = textColor;
  599.         }
  600.         else
  601.         {
  602.             tempColor = disabledTextColor;
  603.         }
  604.  
  605.  
  606.         switch(hAlignStyle)
  607.         {
  608.             case ALIGN_LEFT:
  609.                 //Align with the left edge and add a one pixel margin.
  610.                 xPos = bevel + 2;
  611.                 break;
  612.             case ALIGN_RIGHT:
  613.                 //Align with the right edge and add a one pixel margin.
  614.                 xPos = s.width - 3 - bevel - labelWidth;
  615.                break;
  616.             case ALIGN_CENTERED:
  617.                 xPos = (s.width - labelWidth) >> 1;
  618.                 break;
  619.         }
  620.  
  621.         switch(vAlignStyle)
  622.         {
  623.             case ALIGN_TOP:
  624.                 //Align with the top edge and add a one pixel margin.
  625.                 yPos = bevel + 2 + fm.getAscent();
  626.                 break;
  627.             case ALIGN_BOTTOM:
  628.                 //Align with the bottom edge and add a one pixel margin.
  629.                 yPos = s.height - 3 - bevel - fm.getDescent();
  630.                 break;
  631.             case ALIGN_CENTERED:
  632.                 yPos = (s.height + fm.getAscent()) >> 1;
  633.                 break;
  634.         }
  635.  
  636.         buttonImageGraphics.setColor(tempColor);
  637.         buttonImageGraphics.drawString(sLabelButton, xPos + pressedAdjustment, yPos + pressedAdjustment);
  638.     }
  639.  
  640.     /**
  641.      * The button label text.
  642.      */
  643.     protected String sLabelButton;
  644.     /**
  645.      * The text vertical alignment style.
  646.      * The value is one of: ALIGN_TOP, ALIGN_CENTERED, or ALIGN_BOTTOM
  647.      * @see #getVerticalAlignStyle
  648.      * @see #setVerticalAlignStyle
  649.      * @see #ALIGN_TOP
  650.      * @see AlignStyle#ALIGN_CENTERED
  651.      * @see #ALIGN_BOTTOM
  652.      */
  653.     protected int vAlignStyle;
  654.     /**
  655.      * The text horizontal alignment style.
  656.      * The value is one of: ALIGN_LEFT, ALIGN_CENTERED, or ALIGN_RIGHT
  657.      * @see #getAlignStyle
  658.      * @see #setAlignStyle
  659.      * @see AlignStyle#ALIGN_LEFT
  660.      * @see AlignStyle#ALIGN_CENTERED
  661.      * @see AlignStyle#ALIGN_RIGHT
  662.      */
  663.     protected int hAlignStyle;
  664.     /**
  665.      * The color used for text when this component is enabled.
  666.      * @see #getTextColor
  667.      * @see #setTextColor
  668.      */
  669.     protected Color textColor            = null;
  670.     /**
  671.      * The color used for text when this component is pressed.
  672.      * This color is automatically determined.
  673.      */
  674.     protected Color pressedTextColor    = null;
  675.     /**
  676.      * The color used for text when this component is disabled.
  677.      * This color is automatically determined.
  678.      */
  679.     protected Color disabledTextColor    = null;
  680.  
  681.     /**
  682.      * Error strings.
  683.      */
  684.     transient protected ResourceBundle errors;
  685.  
  686.     private HAVeto    horizontalVeto    = null;
  687.     private VAVeto    verticalVeto    = null;
  688.     private symantec.itools.beans.VetoableChangeSupport vetos = new symantec.itools.beans.VetoableChangeSupport(this);
  689.     private symantec.itools.beans.PropertyChangeSupport changes = new symantec.itools.beans.PropertyChangeSupport(this);
  690. }
  691.  
  692.